package com.course.cdspringboot.mapper.achievement;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.course.cdspringboot.entity.achievement.AchievementAcademicExchange;
import com.course.cdspringboot.entity.achievement.AchievementPatent;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface AchievementAcademicExchangeMapper extends BaseMapper<AchievementAcademicExchange> {

    @Select("SELECT count(*) FROM achievement_academic_exchange WHERE report_name = #{report_name}")
    int countByExchangeName(String report_name);

    @Select("<script>" +
            "SELECT achievement_academic_exchange.*, review_status.name review_status, achievements.created_date, achievements.review_comments " +
            "FROM achievement_academic_exchange " +
            "JOIN achievements ON achievement_academic_exchange.achievement_id = achievements.achievement_id " +
            "JOIN review_status ON achievements.review_status_id = review_status.id " +
            "WHERE achievements.is_deleted=false AND achievement_academic_exchange.achievement_id IN " +
            "<foreach item='item' index='index' collection='ids' " +
            "open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    List<AchievementAcademicExchange> selectByAchievementIds(@Param("ids") List<Integer> ids);


//    @Update("UPDATE achievement_academic_exchange " +
//            "SET report_name = #{report_name}, " +
//            "    venue = #{venue}, " +
//            "    conference_name = #{conference_name}, " +
//            "    organizer = #{organizer}, " +
//            "    is_special_invitation = #{is_special_invitation}, " +
//            "    conference_date = #{conference_date}, " +
//            "    remarks = #{remarks}, " +
//            "    submission_date = #{submission_date} " +
//            "WHERE achievement_id = #{achievement_id} AND " +
//            "achievement_id IN (SELECT achievement_id FROM achievements WHERE Owner=#{uid});")
//    void updateAcademicExchange(Map<String, Object> achievement_academic_exchange_info);
}
